package PortAudioAda.ASIO is

   -----------------------------------------------------------------------------
   --  Retrieve legal native buffer sizes for the specificed device, in sample
   --  frames.
   --
   --  Parameters
   --     device
   --        The global index of the device about which the query is being made.
   --     minBufferSizeFrames
   --        A pointer to the location which will receive the minimum buffer
   --        size value.
   --     maxBufferSizeFrames
   --        A pointer to the location which will receive the maximum buffer
   --        size value.
   --     preferredBufferSizeFrames
   --        A pointer to the location which will receive the preferred buffer
   --        size value.
   --     granularity
   --        A pointer to the location which will receive the "granularity".
   --        This value determines the step size used to compute the legal
   --        values between minBufferSizeFrames and maxBufferSizeFrames. If
   --        granularity is -1 then available buffer size values are powers
   --        of two.
   --
   --  See Also: ASIOGetBufferSize in the ASIO SDK.
   --
   --  Note: this function used to be called PaAsio_GetAvailableLatencyValues.
   --  There is a rename that maps PaAsio_GetAvailableLatencyValues to this
   --  function for backwards compatibility.
   function PaAsio_GetAvailableBufferSizes
     (device                    :        PaDeviceIndex;
      minBufferSizeFrames       : access IC.unsigned_long;
      maxBufferSizeFrames       : access IC.unsigned_long;
      preferredBufferSizeFrames : access IC.unsigned_long;
      granularity               : access Integer)
      return PaError;
   pragma Import (C,
                  PaAsio_GetAvailableBufferSizes,
                  "PaAsio_GetAvailableBufferSizes");

   -----------------------------------------------------------------------------
   --  Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
   --
   --  See PaAsio_GetAvailableBufferSizes

   function PaAsio_GetAvailableLatencyValues
     (device                    :        PaDeviceIndex;
      minBufferSizeFrames       : access IC.unsigned_long;
      maxBufferSizeFrames       : access IC.unsigned_long;
      preferredBufferSizeFrames : access IC.unsigned_long;
      granularity               : access Integer)
      return PaError
      renames PaAsio_GetAvailableBufferSizes;

   -----------------------------------------------------------------------------
   --  Display the ASIO control panel for the specified device.
   --
   --  device
   --     The global index of the device whose control panel is to be displayed.
   --  systemSpecific
   --     On Windows, the calling application's main window handle,
   --     on Macintosh this value should be zero.
   function PaAsio_ShowControlPanel (device         : PaDeviceIndex;
                                     systemSpecific : System.Address)
                                     return PaError;
   pragma Import (C, PaAsio_ShowControlPanel, "PaAsio_ShowControlPanel");

   -----------------------------------------------------------------------------
   --  Retrieve a pointer to a string containing the name of the specified
   --  input channel. The string is valid until Pa_Terminate is called.
   --
   --  The string will be no longer than 32 characters including the null
   --  terminator.
   function PaAsio_GetInputChannelName (device       :        PaDeviceIndex;
                                        channelIndex :        Integer;
                                        error        : access PaError)
                                        return String;
   pragma Inline (PaAsio_GetInputChannelName);

   -----------------------------------------------------------------------------
   --  Retrieve a pointer to a string containing the name of the specified
   --  output channel. The string is valid until Pa_Terminate is called.
   --
   --  The string will be no longer than 32 characters including the null
   --  terminator.
   function PaAsio_GetOutputChannelName (device       :        PaDeviceIndex;
                                         channelIndex :        Integer;
                                         error        : access PaError)
                                         return String;
   pragma Inline (PaAsio_GetOutputChannelName);

   -----------------------------------------------------------------------------
   --  Set the sample rate of an open paASIO stream.
   --
   --  stream
   --     The stream to operate on.
   --  sampleRate
   --     The new sample rate.
   --
   --  Note that this function may fail if the stream is alredy running and the
   --  ASIO driver does not support switching the sample rate of a running
   --  stream.
   --
   --  Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
   function PaAsio_SetStreamSampleRate (stream     : PaStream;
                                        sampleRate : Long_Float)
                                        return PaError;
   pragma Import (C, PaAsio_SetStreamSampleRate, "PaAsio_SetStreamSampleRate");

   -----------------------------------------------------------------------------

   paAsioUseChannelSelectors : constant IC.unsigned_long := 16#01#;

   type PaAsioStreamInfo is
      record
         --  PaAsioStreamInfo'Size / 8
         size             : aliased IC.unsigned_long;
         hostApiType      : aliased PaHostApiTypeId;    -- paASIO */
         version          : aliased IC.unsigned_long;   -- 1 */

         flags            : aliased IC.unsigned_long;

         --  Support for opening only specific channels of an ASIO device.
         --  If the paAsioUseChannelSelectors flag is set, channelSelectors is a
         --  pointer to an array of integers specifying the device channels to
         --  use. When used, the length of the channelSelectors array must match
         --  the corresponding channelCount parameter to Pa_OpenStream otherwise
         --  a crash may result.
         --  The values in the selectors array must specify channels within the
         --  range of supported channels for the device or paInvalidChannelCount
         --  will result.
         channelSelectors : access Integer;
      end record;
   pragma Convention (C, PaAsioStreamInfo);

end PortAudioAda.ASIO;
